package com.ai.aiagent.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

//@Component
public class SpringAiAiInvoke implements CommandLineRunner{

    @Resource
    private ChatModel dashscopeChatModel;


    @Override
    public void run(String... args) throws Exception {
        // 目前千问plus只支持流式调用
        dashscopeChatModel.stream(new Prompt("你是谁?"))
                .subscribe(chatResponse -> {
                    System.out.print(chatResponse.getResult().getOutput().getText());
                });
    }
}
